package com.qyer.commons.service.resources;

import static com.qyer.commons.http.HttpResult.DEFAULT_STRA;
import static com.qyer.commons.service.conf.CommonsMetaInfo.NAMESPACE;
import static com.qyer.commons.service.conf.CommonsMetaInfo.SERVICE_NAME;
import static com.qyer.commons.utils.CommonUtils.getRequestId;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;

import com.codahale.metrics.annotation.Timed;
import com.google.common.collect.Maps;
import com.qyer.commons.http.HttpResult;
import com.qyer.commons.http.NormalHttpResult;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import java.util.Map;

/**
 * User: Z J Wu Date: 2016/02/18 Time: 15:00 Package: com.qyer.words.app
 */
@Path("/")
@Produces(APPLICATION_JSON + "; charset=utf-8")
public class RootResource {

  public RootResource() {
  }

  @GET @Timed public HttpResult translate() {
    long t1 = System.currentTimeMillis();
    Map<String, Long> map = Maps.newHashMapWithExpectedSize(1);
    map.put("current_time_in_milli", System.currentTimeMillis());
    return NormalHttpResult
      .createNormalResult(SERVICE_NAME, NAMESPACE, getRequestId(), DEFAULT_STRA,
                          System.currentTimeMillis() - t1, map);
  }
}
